package com.server.questionbank.snframe.util.FileUtil.operation.command;


import com.server.questionbank.snframe.util.FileUtil.operation.base.AbstractOperation;
import io.minio.MinioClient;
import io.minio.ObjectWriteResponse;
import io.minio.PutObjectArgs;

import java.io.InputStream;

public class UploadCommand extends AbstractOperation<ObjectWriteResponse> {
    private final InputStream content;
    private final long size;
    private final String contentType;

    public UploadCommand(MinioClient minioClient, String bucket, String object, 
            InputStream content, long size, String contentType) {
        super(minioClient, bucket, object);
        this.content = content;
        this.size = size;
        this.contentType = contentType;
    }

    @Override
    protected ObjectWriteResponse doExecute() throws Exception {
        return minioClient.putObject(
            PutObjectArgs.builder()
                .bucket(bucket)
                .object(object)
                .stream(content, size, -1)
                .contentType(contentType)
                .build()
        );
    }

    @Override
    public void validate() {
        super.validate();
//        if (content == null) {
//            throw new IllegalArgumentException("Content cannot be null");
//        }
//        if (size <= 0) {
//            throw new IllegalArgumentException("Size must be positive");
//        }
    }
} 